var app = angular.module("moGu");
app.controller("catetoryCtrl",["$scope","$http",function($scope,$http){
	$('.home_headerImg1').on('click',function(){
    window.location.replace("#/login")
  })
  $('.home_headerImg2').on('click',function() {
    window.location.replace("#/car")
  })
	//设置鼠标点击，li背景变成白色，并增加红竖线——————————————————————————————————
	$scope.isActive = false;
	$scope.changeStyle = function(){
		$scope.isActive = false;
			$("#catetoryBox_left ul li a").removeClass("active");
		this.isActive = true;
		console.log(this);
		$scope.catetorySrc = this.$$watchers[2].last;
		console.log($scope.catetorySrc)
		$http({
			method:"GET",
			url:"catetory/cateoryData/src"+$scope.catetorySrc+"/1.json"
		}).then(function(obj){
			console.log(obj.data.data);
			// console.log(obj.data.data.bannerHead.list);
			if(obj.data.data.bannerHead != undefined){
					if( obj.data.data.bannerHead.list == []){
							$scope.bannerHead = [];
					}
					$scope.bannerHead = obj.data.data.bannerHead.list;
			}
			console.log(obj.data.data.toufuNavigation);
			if(obj.data.data.toufuNavigation != undefined){
					$scope.toufuNavigation = obj.data.data.toufuNavigation.list;
			}else{
					$scope.toufuNavigation = [];
			}
			$scope.dataRight = obj.data.data.categoryNavigation.list;
		},function(err){
			console.log(err)
		});
		$http({
			method:"GET",
			url:"catetory/cateoryData/src"+$scope.catetorySrc+"/2.json"
		}).then(function(obj){
			// console.log(obj.data);
			$scope.dataRightNav = obj.data.result.sortFilter;
		},function(err){
			console.log(err)
		});
		$http({
			method:"GET",
			url:"catetory/cateoryData/src"+$scope.catetorySrc+"/3.json"
		}).then(function(obj){
			console.log(obj.data.result.wall.docs);
			$scope.dataRightBottom = obj.data.result.wall.docs;
		},function(err){
			console.log(err)
		});
	}
	//请求数据左侧数据————————————————————————————————————————————————————
	$http({
		method:"GET",
		url:"./catetory/cateoryData/cateoryLeft.json"
	}).then(function(obj){
//		console.log(obj.data.data[41789].list);
		$scope.dataLeft = obj.data.data[41789].list;
	},function(err){
		console.log(err)
	});
	//请求数据右侧上面的数据————————————————————————————————————————————————————
	$http({
		method:"GET",
		url:"./catetory/cateoryData/fashionTop.json"
	}).then(function(obj){
//		console.log(obj.data.data.categoryNavigation.list);
		$scope.dataRight = obj.data.data.categoryNavigation.list;
	},function(err){
		console.log(err)
	});
	//请求数据导航的数据————————————————————————————————————————————————————
	$http({
		method:"GET",
		url:"./catetory/cateoryData/fashionBottom1.json"
	}).then(function(obj){
//		console.log(obj.data.result.sortFilter);
		$scope.dataRightNav = obj.data.result.sortFilter;
	},function(err){
		console.log(err)
	});
	//请求数据导航下面的数据————————————————————————————————————————————————————
	$http({
		method:"GET",
		url:"./catetory/cateoryData/fashionBottom1.json"
	}).then(function(obj){
		console.log(obj.data.result.wall.docs);
		$scope.dataRightBottom = obj.data.result.wall.docs;
	},function(err){
		console.log(err)
	});
	$(".catetoryBox_right_content").scroll(function(){
			console.log("asdf");
	})

	$scope.scrollBanner = function(){
		$("#catetoryBox_right").scroll(function(){
			if($("#catetoryBox_right")[0].scrollTop>700){
				$(".catetoryBox_right_content_nav").css({
					"width":"77%",
					"position":"fixed",
					"top":"-0.09rem",
					"rigth":"0"
				});
			}else if($("#catetoryBox_right")[0].scrollTop<657){
				$(".catetoryBox_right_content_nav").css({
					"width":"100%",
					"position":"static",
					"top":"-0.3rem"
				});
			}
		})
	}
	$("#catetoryBox_left ul").mouseover(function(){
		$("#catetoryBox_left ul li").each(function(index,ele){
			$(ele).click(function(){
				$("#catetoryBox_left ul li").each(function(index1,ele1){
					$(ele1).removeClass("active");
				})
				$(this).addClass("active");
			})
		})
	})
	$("#catetoryBox_right").trigger("click");
	$("#catetoryBox_left ul").trigger("mouseover");
	$($("#catetoryBox_left ul li")[0]).trigger("click");
}]);
